import { defineStore } from 'pinia'

export const useMainStore = defineStore('main', {
    state: () => ({
        selectArr: localStorage.getItem('selectArr') ? JSON.parse(localStorage.getItem('selectArr')!) : [],
    }),

    actions: {
        setSelectArr(data: any) {
            this.selectArr.push(data)
            localStorage.setItem('selectArr', JSON.stringify(this.selectArr))
        },
        removeSelectArr(id: any) {
            console.log(id)
            //删除
            this.selectArr = this.selectArr.filter((item: any) => item.id !== id)
            console.log(this.selectArr)
            localStorage.setItem('selectArr', JSON.stringify(this.selectArr))
        }
    }
})
